package com.qtenv.datasync.service.controller;


import com.qtenv.datasync.base.Result;
import com.qtenv.datasync.service.service.ZoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 层级表 前端控制器
 * </p>
 *
 * @author CBL
 * @since 2022-08-02
 */
@RestController
@RequestMapping("/zone")
public class ZoneController {
    @Autowired
    private ZoneService zoneService;

    @GetMapping("/getMeteringZones")
    public Result<?> getMeteringZones(@RequestParam("tenantId") String tenantId) {
        System.out.println("zone getMeteringZones");
        return Result.ok(zoneService.getZones(tenantId, "1,2"));
    }

    @GetMapping("/getBuildingZones")
    public Result<?> getBuildingZones(@RequestParam("tenantId") String tenantId) {
        System.out.println("zone getBuildingZones");
        return Result.ok(zoneService.getZones(tenantId, "4"));
    }

    @GetMapping("/getSeniorZones")
    public Result<?> getSeniorZones(@RequestParam("tenantId") String tenantId) {
        System.out.println("zone getSeniorZones");
        return Result.ok(zoneService.getZones(tenantId, "3"));
    }

    @GetMapping("/getChildDmaList")
    public Result<?> getChildDmaList(@RequestParam("tenantId") String tenantId, @RequestParam("areaId") String areaId) {
        return Result.ok(zoneService.getChildDmaList(tenantId, areaId));
    }

    @GetMapping("/getChildSeniorList")
    public Result<?> getChildSeniorList(@RequestParam("tenantId") String tenantId, @RequestParam("areaId") String areaId) {
        return Result.ok(zoneService.getChildSeniorList(tenantId, areaId));
    }

    @GetMapping("/getAllSeniorDataList")
    public Result<?> getAllSeniorDataList(@RequestParam("tenantId") String tenantId, @RequestParam(value = "areaName", required = false) String areaName,
                                            @RequestParam(value = "pageSize", required = false, defaultValue = "10") String pageSize,
                                            @RequestParam(value = "page", required = false, defaultValue = "1") String page) {
        System.out.println("zone getTerminals");
        return Result.ok(zoneService.getAllSeniorDataList(tenantId, areaName, page, pageSize));
    }
}
